﻿using Npgsql;
using Real.Datos.Interfaces;
using Real.Entidad;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Text;
using DapperExtensions;
using Dapper;

namespace Real.Datos.Repositories
{
    public interface ICategoriaRepository : IRepository<Categoria>
    {

    }

    public class CategoriaRepository : ICategoriaRepository
    {
        protected readonly IDbConnection _db;

        public CategoriaRepository()
        {
            _db = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["REAL"].ToString()); 
        }

        public IList<Categoria> FindAll()
        {
            using (IDbConnection _db = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["REAL"].ToString()))
            {
                return _db.Query<Categoria>("SELECT * FROM CATEGORIA").ToList();
            }           
        }

        public IList<Categoria> Find(System.Linq.Expressions.Expression<Func<Categoria, bool>> predicate)
        {
            throw new NotImplementedException();
        }

        public Categoria FindById(int id)
        {
            throw new NotImplementedException();
        }

        public int Add(Categoria newEntity)
        {
            throw new NotImplementedException();
        }

        public bool Remove(int id)
        {
            throw new NotImplementedException();
        }

        public int Modify(Categoria entity)
        {
            throw new NotImplementedException();
        }
    }
}
